package com.EJ.ejcompanyweb.Util;


import io.reactivex.subjects.PublishSubject;

public final class RxBus {

    private final PublishSubject<Object> bus = PublishSubject.create();
    private static RxBus instance;
    private RxBus(){}

    public void send(final Object event) {
        bus.onNext(event);
    }

    public PublishSubject<Object> toObservable() {
        return bus;
    }

    public boolean hasObservers() {
        return bus.hasObservers();
    }

    public static RxBus getInstance() {
        if (instance==null){
            instance=new RxBus();
        }
        return instance;
    }
}
